package com.ces.chain;

import java.lang.reflect.Method;

/*
 * @Author wuchengcheng
 * @Date 2019-10-13 15:15
 */
// 封装了被访问者（即目标对象）的信息
public class Invocation {
    private final Object target;
    private final Method method;
    private final Object[] args;

    public Invocation(Object target, Method method, Object[] args) {
        this.target = target;
        this.method = method;
        this.args = args;
    }

    // 此处的proceed，就相当于责任链中调用下一个具体实现
    public Object proceed() throws Exception{
        return method.invoke(target,args);
    }

    public Object getTarget() {
        return target;
    }

    public Method getMethod() {
        return method;
    }

    public Object[] getArgs() {
        return args;
    }
}
